package cn.tedu.yl.register.service.impl;

import cn.tedu.yl.register.mapper.RegisterMapper;
import cn.tedu.yl.register.pojo.dto.RegisterQuery;
import cn.tedu.yl.register.pojo.dto.RegisterSaveParam;
import cn.tedu.yl.register.pojo.entity.Register;
import cn.tedu.yl.register.pojo.vo.RegisterVO;
import cn.tedu.yl.register.service.RegisterService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class RegisterServiceImpl implements RegisterService {
    @Autowired
    private RegisterMapper registerMapper;
    @Override
    public void save(RegisterSaveParam registerSaveParam) {
        Register register=new Register();
        BeanUtils.copyProperties(registerSaveParam,register);
        if (register.getId()==null){

        registerMapper.insertRegister(register);
        }
        else {
            registerMapper.updateRegister(register);
        }
    }

    @Override
    public List<RegisterVO> select(RegisterQuery registerQuery) {
       return registerMapper.selectRegister(registerQuery);
    }
}
